######################################################
# skt - generate ln config files for gdaq for ETF, IMP
#
# CMakeLists.txt for compilation of library skt
# Author SUN Yazhou
# Created: 2023/04/14
# Last modified: 2020/04/14
######################################################

cmake_minimum_required(VERSION 3.12)

# find_program(CLANG_EXECUTABLE clang++)
# find_program(GXX_EXECUTABLE g++)
# if(CLANG_EXECUTABLE)
# set(CMAKE_CXX_COMPILER "clang++")
# set(CMAKE_C_COMPILER "clang")
# elseif(GXX_EXECUTABLE)
# set(CMAKE_CXX_COMPILER "g++")
# set(CMAKE_C_COMPILER "gcc")
# else()
# message(FATAL_ERROR "No CXX compilers were found")
# endif()

project(skt)

set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}")
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")

# Build Type: MinSizeRel Debug Release RelWithDebInfo
# set(BUILD_TYPE Debug) # appropriate for DEBUG, yet rather slow
set(BUILD_TYPE Release) # compiler-optimized, extreme performance
# set(BUILD_TYPE MinSizeRel) # rel, and with minized lib and exe size
# set(BUILD_TYPE RelWithDebInfo) # rel, and with DEB info
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${BUILD_TYPE})
else()
set(BUILD_TYPE ${CMAKE_BUILD_TYPE})
endif()

# copy the config files to the build directory
file(GLOB VAR ${CMAKE_SOURCE_DIR}/config/sh/*.sh)
file(COPY ${VAR} DESTINATION ${CMAKE_BINARY_DIR})

add_subdirectory(skt)
add_subdirectory(src)


# print the build type
string(TOUPPER ${BUILD_TYPE} BUILD_TYPE_UPPER)
execute_process(
  COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
  OUTPUT_VARIABLE COMPILER_VERSION
)
string(STRIP ${COMPILER_VERSION} COMPILER_VERSION_STRIPPED)
message(STATUS "======= BUILD TYPE ===========")
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER} ${COMPILER_VERSION_STRIPPED}")
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}   ${CMAKE_CXX_FLAGS_${BUILD_TYPE_UPPER}}")
message(STATUS "(TIPS: Change with -DCMAKE_BUILD_TYPE=<build_type>)")
message(STATUS "(TIPS: Available build_type-s: MinSizeRel Debug Release RelWithDebInfo)")
message(STATUS "======= BUILD TYPE ===========")
